package com.tougutips.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tougutips.common.core.constant.MqConstants;
import com.tougutips.entity.SeckillGoods;
import com.tougutips.mapper.SeckillGoodsMapper;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class SeckillGoodsService extends ServiceImpl<SeckillGoodsMapper, SeckillGoods> implements IService<SeckillGoods> {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 新增秒杀活动业务
     * @param goods
     * @return
     */
    public boolean save(SeckillGoods goods){
        // 向通知队列发送秒杀活动信息
        rabbitTemplate.convertAndSend(MqConstants.EXCHANGE_FANOUT,MqConstants.ROUTINGKEY_NULL,goods);
        return super.save(goods);
    }

}
